package org.hughie.web;

import org.hughie.model.FundSearchResult;
import org.hughie.model.WebRespWrapper;
import org.hughie.service.FundQueryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hughie.cheng
 * @date 2024/3/8
 */
@RestController
public class FundQueryController {

    private FundQueryService service;

    public FundQueryController(FundQueryService service) {
        this.service = service;
    }

    /**
     * 条件查询基金列表
     */
    @GetMapping("search")
    WebRespWrapper<List<FundSearchResult>> queryByKey(@RequestParam String key) {
        return WebRespWrapper.success(service.queryByKey(key));
    }

    /**
     * 条件查询并保存基金列表
     */
    @GetMapping("save")
    WebRespWrapper<List<FundSearchResult>> saveByKey(@RequestParam String key) {
        return WebRespWrapper.success(service.saveByKey(key));
    }

}
